Repository navigation
Settings Get: Honor a comma-separated fields filter - #1161
maheshbohara wants to merge 4 commits into
Conversation
Schema validation accepts a comma-separated string for the `fields` list, but execute_get_settings() only read an array. A string filter was dropped without an error and every exposed setting was returned when the ability was executed directly. The filter is now read with wp_parse_list(), as core/content-query reads its list inputs. See WordPress#1160.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1161 +/- ##
==========================================
Coverage 82.17% 82.18%
- Complexity 3399 3400 +1
==========================================
Files 136 136
Lines 13187 13189 +2
==========================================
+ Hits 10837 10839 +2
Misses 2350 2350
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@jorgefilipecosta, where did we land at supporting comma-separated |
|
If I follow the code correctly, it's been patched in both WP core and AI plugin: ai/includes/Abilities/Settings/Settings.php Lines 182 to 184 in 95af2c6 |
|
I confirmed that it had been superseded by #1206. We also want to go one step further and coerce the input on the Abilties API level to mirror how REST API does it with WordPress/wordpress-develop#14882. |
|
@maheshbohara, thank you for the report and the fix proposed. |
What?
Closes #1160
Makes
core/settings-gethonor a comma-separatedfieldsfilter when the ability is executed directly.Why?
The input schema declares
fieldsas an array of strings, and schema validation accepts a comma-separated string for an array.execute_get_settings()only read an array, so"blogname,siteurl"passed validation, was dropped without an error, and every exposed setting was returned. Details and commands are in #1160.The REST route is not affected, because the REST layer turns the string into an array before the ability runs. The problem shows for in-process callers: PHP, WP-CLI, or anything that calls
execute()itself.How?
execute_get_settings()readsfieldswithwp_parse_list()and keeps the string items, the same waycore/content-queryreads its list inputs (parse_list_input()inContent.php).fieldsvalue. It fails ondevelop.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus
Used for: Investigation, implementation, tests, manual testing, and PR wording. I reviewed the changes and the test results, and I take responsibility for the contribution.
Testing Instructions
core/settings-get.2. Ondevelopit prints the number of all exposed settings (19on my site).array( "fields" => array( "blogname", "siteurl" ) )still prints2, and an empty input still returns every setting.Results on my site (WordPress 7.1.3, wp-env, PHP 8.3) with this branch:
Automated:
npm run test:phppasses (1903 tests), including the new test.composer lintand PHPStan pass.Changelog Entry